#region Using Directives
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Secure.Client;

#endregion

namespace Secure.Tests.Client
{
    [TestFixture]
    public class XmlSecureClientConfigurationFixture
    {
        [Test]
        public void should_add_a_user_to_a_role()
        {
            ISecureClient client = new XmlSecureClient();

            client.AddUserToRole("david", "manager", "1", "2", "3");

            string[] additionalParams;
            Assert.IsTrue(client.IsUserInRole("david", "manager", out additionalParams));
            Assert.AreEqual(new [] {"1", "2", "3"}, additionalParams);
        }

        [Test]
        public void should_load_client_from_app_configuration()
        {
            ISecureClient client = new XmlSecureClient();
            XmlSecureClientConfigurator.Configure(client);

            string[] davidParams;
            bool davidIsInRole = client.IsUserInRole("david", "manager", out davidParams);

            Assert.IsTrue(davidIsInRole);
            Assert.AreEqual(new [] {"2", "5", "23"}, davidParams);

            string[] steveParams;
            bool steveIsInRole = client.IsUserInRole("steve", "manager", out steveParams);

            Assert.IsTrue(steveIsInRole);
            Assert.AreEqual(new[] {"7", "8", "9"}, steveParams);

            string[] maryParams;
            bool maryIsInRole = client.IsUserInRole("mary", "manager", out maryParams);

            Assert.IsFalse(maryIsInRole);
            Assert.AreEqual(new string[0], maryParams);
        }
    }
}